
import 'package:assistant_zhao/fin_chatbot_demo.dart';
import 'package:assistant_zhao/freight_smart_login_page.dart';
import 'package:assistant_zhao/my_home_tab_page.dart';
import 'package:flutter/material.dart' deferred as material
    show MaterialApp, ThemeData, AppBarTheme, Colors, TargetPlatform, Locale;
import 'package:mpflutter_core/mpflutter_core.dart' deferred as mpcore;
import 'package:mpflutter_wechat_api/mpflutter_wechat_api.dart' deferred as wxapi;

void main() async {
  await material.loadLibrary();
  await mpcore.loadLibrary();
  await wxapi.loadLibrary();
  mpcore.runMPApp(material.MaterialApp(
      title: 'Flutter Demo',
      theme: material.ThemeData(
        useMaterial3: true,
        appBarTheme: material.AppBarTheme(
          color: material.Colors.blue,
          foregroundColor: material.Colors.white,
          elevation: 5.0,
          centerTitle: false,
        ),
        /**
         * 使用 iOS 风格页面转场
         */
        platform: material.TargetPlatform.iOS,
      ),
      routes: {
        '/home': (context) => MyHomeTabPage(title: 'FreightSmart'),
        '/fin_chatbot_demo': (context) => FinChatBotView(),
        '/login': (context) => FreightSmartLoginPage(),
      },
      home: FreightSmartLoginPage(),
      /**
       * 务必保留 MPNavigatorObserver，否则小程序的路由会出问题。
       */
      navigatorObservers: [mpcore.MPNavigatorObserver()],
    ));

  /**
   * 务必保留这段代码，否则第一次调用 wx 接口会提示异常。
   */
  if (mpcore.kIsMPFlutter) {
    try {
      wxapi.wx.$$context$$;
    } catch (e) {}
  }

}